import React, { Component } from 'react'
import axios from 'axios'

export default class AxiosTest extends Component {
    let 
    handleAxiosGet = () => {
        this.state = {
            contant : ''
        }
        //这里是json-server本地服务器
        axios.get('http://localhost:3000/posts').then(
           response => {
               console.log(JSON.stringify(response.data) + 'request is successed')
        },
           error => {
               console.log(JSON.stringify(error) + 'request is not successed')
           }
        )
    }
    render() {
        return (
            <div>
                <h3>react + axios</h3>
                <button onClick={this.handleAxiosGet}>点击查询一些作者数据</button>
                <div></div>
            </div>
        )
    }
}
